﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Microsoft.Directx.Sound;




namespace WindowsFormsApplication1
{
    static class Sound
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());



            //Create and setup the sound device.
            Device dev = new Device();
            dev.SetCooperativeLevel(this, CooperativeLevel.Normal);

            //Create and setup the buffer description.
            BufferDescription buffer_desc = new BufferDescription();
            buffer_desc.ControlEffects = true; //this has to be true to use effects.
            buffer_desc.GlobalFocus = true; //play sound even if application loses focus.

            //Create and setup the buffer for playing the sound.
            SecondaryBuffer buffer = new SecondaryBuffer(@"C:\WINDOWS\Media\ding.wav",buffer_desc,dev);

            //Create an array of effects descriptions, 
            //set the effect objects to echo and chorus and 
            //set it in the buffer.
            EffectDescription[] effects = new EffectDescription[2];
            effects[0].GuidEffectClass = DSoundHelper.StandardEchoGuid;
            effects[1].GuidEffectClass = DSoundHelper.StandardChorusGuid;
            buffer.SetEffects(effects);

            //Play Buffer.
            buffer.Play(0, BufferPlayFlags.Default);

        }
    }
}
